import * as types from '../actionType'
import { getToken } from '@/utils/auth'
// 登录功能，只需要存储 token 即可，所以，状态默认值为：''
const initialState = {
    token: getToken(), // 这里从本地存储中读取token
    userInfo: {}
}

export default function user(state = initialState, action) {
    switch (action.type) {
        case types.SET_TOKEN:
            return { ...state, token: action.payload }
        case types.UPDATE_USERINFO:
            return { ...state, userInfo: action.payload }
        default:
            return state
    }
}
